// import { Modal } from "antd-mobile";
class Helper {
  constructor() {
    this.$ = window.$ || window.jQuery;
  }

  Toast(info, time = 2) {
    const $ = this.$;
    const str = `<div class="toast">${info}</div>`;
    if (!info) return;
    $("body").append(str);
    setTimeout(() => {
      $("body")
        .find(".toast")
        .remove();
    }, time * 1000);
  }

  goLogin(history, path) {
    const search = history.location.search ? history.location.search : "?";
    const pathname = path || history.location.pathname;
    const url = `/user/register${search}${
      search === "?" ? "" : "&"
    }redirect=${pathname}&one=is`;

    history.listen(location => {
      console.log(
        `The current URL is ${location.pathname}${location.search}${
          location.hash
        }`
      );
    });

    const go = url => {
      history.push(url);
    };

    go(url)

    // Modal.alert("", "请先登录", [
    //   { text: "稍后", style: "default" },
    //   { text: "登录", onPress: () => go(url) },
    // ]);
  }
}

export default Helper;
